part of '../repository.dart';

const _kWebPurchasedSubscriptionTransactionRegularOfferTypeValue = 'regular';

class _WebPurchasedSubscriptionTransactionOfferTypeDto extends Equatable {
  const _WebPurchasedSubscriptionTransactionOfferTypeDto._internal({
    required this.offerTypeString,
  });

  final String offerTypeString;

  @override
  List<Object?> get props {
    return [
      offerTypeString,
    ];
  }

  factory _WebPurchasedSubscriptionTransactionOfferTypeDto.fromString(String offerTypeString) {
    return _WebPurchasedSubscriptionTransactionOfferTypeDto._internal(
      offerTypeString: offerTypeString,
    );
  }

  factory _WebPurchasedSubscriptionTransactionOfferTypeDto.fromEntity(
      WebPurchasedSubscriptionTransactionOfferType offerType) {
    late final String offerTypeString;

    if (offerType == WebPurchasedSubscriptionTransactionOfferType.regular) {
      offerTypeString = _kWebPurchasedSubscriptionTransactionRegularOfferTypeValue;
    }

    return _WebPurchasedSubscriptionTransactionOfferTypeDto._internal(
      offerTypeString: offerTypeString,
    );
  }

  @override
  String toString() {
    return offerTypeString;
  }

  WebPurchasedSubscriptionTransactionOfferType toEntity() {
    if (offerTypeString == _kWebPurchasedSubscriptionTransactionRegularOfferTypeValue) {
      return WebPurchasedSubscriptionTransactionOfferType.regular;
    }

    throw UnimplementedError();
  }
}
